<template>
	<view class="bg">

		<u-navbar background="transparent"></u-navbar>
		<image mode="widthFix" src="https://love.soft.haoyangsoft.com/static/wxapp/static/RedBg.png"
			style="width: 100vw;" @click="invite"></image>
			
			
			
			<view style="text-align: center;color: #fff;">
				<view>
					<u-icon name="arrow-up-fill" color="#fff"></u-icon>
				</view>
				<view>点击生成个人二维码海报，可直接发送好友邀请</br>或保存图片发朋友圈</view>
		    </view>

		<button class="btn" @click="Cbtn">
			立即领现金
		</button>


		<view class="u-flex u-row-around step">
			<view style="color: #fff;">
				<view><text style="color: #9BE3DC;font-size: 40rpx;">Step</text><text
						style="margin-left: 20rpx;font-size: 44rpx;">01</text></view>
				<view class="u-font-24 u-margin-top-10">邀请好友</view>
			</view>
			<view style="color: #fff;">
				<view><text style="color: #9BE3DC;font-size: 40rpx;">Step</text><text
						style="margin-left: 20rpx;font-size: 44rpx;">02</text></view>
				<view class="u-font-24 u-margin-top-10">好友注册成功</view>
			</view>
			<view style="color: #fff;">
				<view><text style="color: #9BE3DC;font-size: 40rpx;">Step</text><text
						style="margin-left: 20rpx;font-size: 44rpx;">03</text></view>
				<view class="u-font-24 u-margin-top-10">邀请成功后返现</view>
			</view>

		</view>


		<u-mask :show="showIndex">
			<view class="index-show u-flex">
				<view class="index-show-box">
					<image class="go-pay" src="/static/show-index.png" mode="widthFix" @click="vipCharge"></image>
					<view class="u-flex">
						<image class="close" src="/static/close.png" @click="showIndex = false"></image>
					</view>
				</view>
			</view>
		</u-mask>

	</view>
</template>

<script>
	export default {

		data() {
			return {
				showIndex: !1

			}
		},
		onLoad() {

		},
		methods: {
			vipCharge() {
				this.$u.api.viprRecharge({}).then(res => {
					uni.requestPayment({
						provider: 'wxpay',
						timeStamp: res.timestamp,
						nonceStr: res.noncestr,
						signType: res.signtype,
						paySign: res.paysign,
						appid: res.appid,
						package: res.package,
						success: () => {
							// 支付成功=>微信更新用户信息
							this.$u.toast('支付成功')
						},
						fail: err => {
							this.$u.toast('支付失败')
						},
						complete: err => {
							this.showIndex = false
						}
					})
				})
			},
			Cbtn() {
				this.$store.dispatch('userInfo', this).then(res => {
					if (!res.vip) {
						this.showIndex = !0
					}else{
						uni.navigateTo({
							url:'/pages/mine/account'
						})
					}
					
				})
			},
			invite() {
				this.$u.api.poster().then(res => {
					uni.previewImage({
						urls: [res]
					})
				})
			}
		}
	}
</script>

<style lang="scss">
	.index-show {
		width: 100%;
		height: 100%;
		justify-content: center;

		.index-show-box {
			.go-pay {
				width: 600rpx;
				display: block;
				padding-left: 45rpx;
			}

			.close {
				width: 60rpx;
				height: 60rpx;
				display: block;
				margin: 0 auto;
			}
		}
	}

	.bg {
		background: linear-gradient(180deg, #67EEE4 0%, #00D6C2 100%);
		height: 100vh;
	}

	.btn {
		background: linear-gradient(180deg, #FFAD70 0%, #FF8D11 100%);
		width: 700rpx;
		height: 80rpx;
		color: #fff;
		line-height: 80rpx;
		text-align: center;
		border-radius: 80rpx;
		margin: 40rpx auto;
	}

	.step {
		width: 90%;
		height: 140rpx;
		background: #06B9A8;
		border-radius: 20rpx;
		margin: auto;
		position: absolute;
		bottom: 40rpx;
		left: 5%;
	}
</style>
